package com.cos.shop.web.controller.old;

import com.cos.shop.web.controller.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: COS
 * @time: 2023/5/9 11:31
 * @description:
 */
// @WebServlet("/user")
public class UserController extends BaseServlet {
    public void login(HttpServletRequest req,
                      HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("登录处理页面");
    }

    public String reg(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("登录注册页面");
        req.setAttribute("msg", "注册啦");
       // req.getRequestDispatcher("message.jsp").forward(req,resp);
        // 约定 只要是转发, 都带上字符串 forward:转发地址
        return "forward:message.jsp";
    }
    public String checkName(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //resp.getWriter().println("1");
        // 约定,只要没有带上 forward|redirect就是做字符写出
        return "我就试试看";
    }
    public String logout(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("注销页面");
        //resp.sendRedirect("");
        // 约定 只要是重定向,都带上字符串 redirect:/重定向地址
        return "redirect:/index.jsp";
    }



}
